﻿using adc201406_muzarella.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace adc201406_muzarella.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Index/

        public ActionResult Index()
        {
            var listaDePizzas = new List<Pizza>();
            listaDePizzas.Add(new Muzzarella());
            listaDePizzas.Add(new Fugazzetta());
            listaDePizzas.Add(new Anchoas());
            //listaDePizza.Add(new Roquefort());
            //listaDePizza.Add(new Especial());
            //listaDePizza.Add(new Faina());
            return View(model: listaDePizzas);
        }

        public ActionResult Pedidos()
        {
            var lista = PedidosContainer.pedidos;
            return View(model: lista);
        }

        [HttpPost]
        public ActionResult AgregarPedido(int id, int cantidad)
        {
            Pizza pizza;
            switch (id) {
                case 1: pizza = new Muzzarella();
                    break;
                case 2: pizza = new Fugazzetta();
                    break;
                case 3: pizza = new Anchoas();
                    break;
                default: pizza = null;
                    break;
            }
            Pedido pedido = new Pedido(pizza, cantidad); 
            PedidosContainer.AgregarPedido(pedido);
            return RedirectToAction("Index");
        }
    }
}
